import {
  NODE,
} from "@/components/flow/common/FlowConstant";

/**
 * 初始化节点的按钮权限
 * 按钮权限写到节点的buttonAuth属性下面
 *
 * @param {Object} node 需要设置表单权限的节点
 */
export function initNodeButtonAuth(node) {
  console.log(node)
  let buttonAuth = node.buttonAuth;
  if (!!!buttonAuth) {
    buttonAuth = {
      save: false,
      submit: false,
      agree: false,
      reject: false,
      turn: false,
      back: false,
      revoke: false,
    }
    if (node.type == NODE.APPROVE) {
      buttonAuth.agree = true;
      buttonAuth.reject = true;
      buttonAuth.turn = true;
      buttonAuth.revoke = true;
    } else if (node.type == NODE.TRANSACT) {
      buttonAuth.submit = true;
    } else {
      buttonAuth.save = true;
      buttonAuth.submit = true;
    }
  }
  node.buttonAuth = buttonAuth;
}